<template>
  <view class="page-container">
    <view class="user-profile">
      <image class="avatar" :src="datas.avatar" mode=""></image>
      <text class="username">{{ datas.name }}</text>
      <text class="no">司机编号：{{ datas.number }}</text>
      <text class="mobile">手机号码：{{ datas.phone }}</text>
    </view>
    <view class="month-overview">
      <view class="title">我的任务</view>
      <view class="content">
        <view class="item">
          <text class="volumn">{{ list.taskAmounts }}</text>
          <text class="label">任务总量</text>
        </view>
        <view class="item">
          <text class="volumn">{{ list.completedAmounts }}</text>
          <text class="label">完成任务量</text>
        </view>
        <view class="item">
          <text class="volumn">{{ list.transportMileage }}</text>
          <text class="label">运输里程(km)</text>
        </view>
      </view>
    </view>
    <view class="entry-list">
      <uni-list :border="false">
        <uni-list-item
          to="/subpkg_user/truck/index"
          showArrow
          title="车辆信息"
        />
        <uni-list-item
          to="/subpkg_user/task/index"
          showArrow
          title="任务数据"
        />
        <uni-list-item
          to="/subpkg_user/settings/index"
          showArrow
          title="系统设置"
        />
      </uni-list>
    </view>
  </view>
</template>

<script setup >
import { getDriverUsersAPI,getDriverUsersReportAPI } from '../../api/user'
import { ref } from 'vue'
import dayjs from 'dayjs'
//#region 用户信息
const datas = ref({})
const getDriverUsers = async() => {
  const { data } = await getDriverUsersAPI()
  datas.value=data
}
getDriverUsers()
//#endregion

//#region 任务数据
const list = ref({})
const getDriverUsersReport = async () => {
  // 获取年
  const year =  dayjs().year()  // 2021  当前为2021年
  // 获取月（注意月份从0开始，所以加1）
  const month = dayjs().month('6').add(1, 'month').format('MM');

  const { data } = await getDriverUsersReportAPI(month, year)
 
    list.value=data
 }
getDriverUsersReport()
//#endregion


</script>


<style lang="scss" scoped>
.page-container{
  background-color: #f4f4f4;
  padding-bottom: 109px;
}
.user-profile {
  height: 600rpx;
  padding-top: env(safe-area-inset-top);
  background-image: url(https://sl-driver.oss-cn-hangzhou.aliyuncs.com/images/profile-bg%402x.png);
  background-size: 100% 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  color: #fff;
  line-height: 1.8;
  font-size: 30rpx;

  .avatar {
    width: 140rpx;
    height: 140rpx;
    margin-top: 90rpx;
    border-radius: 50%;
    border: 6rpx solid rgba(255, 255, 255, 0.4);
  }

  .username {
    font-size: 36rpx;
    margin: 10rpx 0;
  }
}
.month-overview {
  height: 268rpx;
  margin: 0 30rpx;
  border-radius: 16rpx;
  background-color: #fff;
  position: relative;
  top: -130rpx;

  .title {
    color: #818181;
    font-size: 30rpx;
    padding-top: 28rpx;
    text-align: center;

    &::after,
    &::before {
      content: '-';
      margin: 0 5rpx;
    }
  }
  .content {
    display: flex;
    justify-content: space-around;
    text-align: center;
    font-size: 30rpx;
    color:#000;
    margin-top: 40rpx;

    .volumn {
      display: block;
      font-size: 36rpx;
      margin-bottom: 20rpx;
      font-weight: 500;
    }
  }
}

.entry-list {
  margin: -100rpx 30rpx 0;
  border-radius: 16rpx;
  overflow: hidden;
}
</style>
